package com.midea.ai.air.ui.more.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.midea.ai.air.R;
import com.midea.ai.air.ui.more.MoreSettingAirExpertShowTemp;
import com.midea.ai.air.ui.more.data.MoreDetailedItem;
import com.midea.ai.air.ui.more.data.MoreMyMessageItem;

import java.util.List;

/**
 * Created by hww on 2016/3/29.
 */
public class MoreSettingAirReportIndoorTempAdapter extends ArrayAdapter<MoreDetailedItem> {

    private LayoutInflater mInflater;

    public MoreSettingAirReportIndoorTempAdapter(Context context, List<MoreDetailedItem> objects) {
        super(context, 0, objects);
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        MoreDetailedItem item = getItem(position);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.list_item_more_air_expert, null);
            holder = new ViewHolder();
            holder.temp = (TextView) convertView.findViewById(R.id.item_more_air_expert_temp);
            holder.time = (TextView) convertView.findViewById(R.id.item_more_air_expert_time);
            holder.line = (View) convertView.findViewById(R.id.item_more_air_expert_line);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.temp.setText(item.getmTemp());
        holder.time.setText(item.getmDate());
        if (position == getCount() - 1) {
            holder.line.setVisibility(View.GONE);
        } else {
            holder.line.setVisibility(View.VISIBLE);
        }
        return convertView;
    }

    class ViewHolder {
        private TextView temp;
        private TextView time;
        private View line;
    }
}
